<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:h="jakarta.faces.html" xmlns:f="jakarta.faces.core" xmlns:ui="jakarta.faces.facelets"
    xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions" xmlns:o="http://omnifaces.org/ui"
    xmlns:sec="https://joinfaces.org/security" template="/template.xhtml">
    <ui:define name="content">

        <p:spacer height="10" />
        <sec:authorize access="hasRole('ROLE_ADMIN')">
            <p:panelGrid columns="1" rendered="#{sec:isFullyAuthenticated()}" layout="grid">
                <p:link title="Logout" href="/logout">
                    <p:outputLabel id="labelRoleAdmin" value="Choose your starter as an ADMIN" />
                </p:link>
            </p:panelGrid>
        </sec:authorize>
        <sec:authorize ifAnyGranted="ROLE_USER">
            <p:panelGrid columns="1" rendered="#{sec:isAuthenticated()}" layout="grid">
                <p:link title="Logout" href="/logout">
                    <p:outputLabel id="labelRoleUser" value="Choose your starter as a regular user" />
                </p:link>
            </p:panelGrid>
        </sec:authorize>
        <sec:anonymous>
            <p:panelGrid columns="1" layout="grid">
                <p:link title="Login" href="/login.faces">
                    <p:outputLabel id="labelAnonymous" value="Choose your starter as anonymous user" />
                </p:link>
            </p:panelGrid>
        </sec:anonymous>
        <p:spacer height="10" />
        <p:selectOneMenu id="locale" value="#{app.locale}" converter="#{localeConverter}" style="width:300px"
            panelStyle="width:300px;height:350px;" height="350px" var="l" filter="true" filterMatchMode="startsWith">
            <f:selectItems value="#{countryService.locales}" var="locale" itemLabel="#{locale.displayLanguage}"
                itemValue="#{locale}" />
            <p:ajax oncomplete="window.location.reload();" />
            <p:column>
                <f:facet name="header">
                    <h:outputText value="app: #{app.locale.locale} : #{app.locale.language}" />
                    <br></br>
                    <h:outputText value="boot: #{app.bootLocale.country} : #{app.bootLocale.language}" />
                    <br></br>
                    <h:outputText value="faces: #{app.faceLocale.country} : #{app.faceLocale.language}" />
                </f:facet>
                <h:outputText value="#{l.displayLanguage}" lang="#{app.locale.locale}" />
            </p:column>
        </p:selectOneMenu>
        <p:spacer height="10" />

    </ui:define>
</ui:composition>